package com.zgg.files.service;

import com.alibaba.fastjson.JSONObject;
import com.zgg.config.AliOssProperties;
import com.zgg.config.datasource.DataSource;
import com.zgg.files.bean.OSSFile;

import java.io.File;
import java.util.List;
import java.util.Map;

public interface UploadService {

    /**
     * 批量上传文件到oss
     *
     * @param fileNames
     * @return
     */
    public void uploadOSSFile(Map<String, String> fileNames, AliOssProperties aliOssProperties, JSONObject callbackJson);


    @DataSource(value = "new_files")
    public void uploadFileInfo(List<OSSFile> ossFiles);

    /**
     * 文件信息入库
     *
     * @param ossFileList
     * @return
     */
    @Deprecated
    @DataSource(value = "new_files")
    public Map<String, String> uploadFileInfo(List<JSONObject> ossFileList, Integer userid, Integer usertype, String pathcode);

    /**
     * 下载文件
     *
     * @param ossFile
     * @param aliOssProperties
     * @return
     */
    public File downOSSFile(OSSFile ossFile, AliOssProperties aliOssProperties);

    @DataSource(value = "new_files")
    public File downOSSFile(List<String> fileId, AliOssProperties aliOssProperties);

    /**
     * @param fileId
     * @param aliOssProperties
     * @return
     */
    public String getOSSFilePath(String fileId, AliOssProperties aliOssProperties);

    /**
     * 修改文件数据库记录
     *
     * @return
     */
    @DataSource(value = "new_files")
    public int updateFileInfo(OSSFile ossFile);

    /**
     * 删除文件数据库记录
     * todo 需要针对表来实现
     *
     * @return
     */
    @DataSource(value = "new_files")
    public int deleteFileInfo(String id, AliOssProperties aliOssProperties);

    /**
     * 根据id查询一条文件记录
     *
     * @param id
     * @return
     */
    @DataSource(value = "new_files")
    public OSSFile findOssFileById(String id);


    /**
     * 根据id查询一条文件记录
     *
     * @param ids
     * @return
     */
    @DataSource(value = "new_files")
    public Map<String, String> getOssFileByIds(List<String> ids, AliOssProperties aliOssProperties);

    /**
     * 根据oss file path查询一条文件记录
     *
     * @param ossFilePath
     * @return
     */
    @DataSource(value = "new_files")
    public OSSFile findOssFileByPath(String ossFilePath);


}
